package one.undefined.Listeners;
import net.dv8tion.jda.api.EmbedBuilder;
import net.dv8tion.jda.api.entities.Member;
import net.dv8tion.jda.api.events.guild.member.GuildMemberJoinEvent;
import net.dv8tion.jda.api.hooks.ListenerAdapter;

public class GuildOnMember extends ListenerAdapter {
    @Override
    public void onGuildMemberJoin(GuildMemberJoinEvent event) {
        Member member = event.getMember();
        EmbedBuilder emebed = new EmbedBuilder()
            .setAuthor(member.getEffectiveName(), member.getUser().getAvatarUrl(), member.getUser().getAvatarUrl())
            .setDescription(member.getEffectiveName() + " зашел к нам :tada:\n"
            + "Давайте поприветствуем его")
            .setFooter(event.getGuild().getName(), event.getGuild().getIconUrl());
        event.getGuild().getSystemChannel().sendMessage(emebed.build()).queue();

        event.getGuild().addRoleToMember(member, event.getGuild().getRoleById("875073174851686482")).queue();
    }
}
